<?php $post = $this->get('post'); ?>
<div class="x-list-title">
	<table width="100%" border="0" height="100%">
	<tr>
		<td align="left">
			<h2>
				Tạo mới công ty 
			</h2>
		</td>
		<td align="right">	
			<div class="x-list-options">

			</div>
		</td>
	</tr>
	</table>	
</div>
<form method="post" action="<?php _actionUrl($this);?>" onsubmit="return ajax_form(this)">
<input type="hidden" name="ID" value="<?php $this->e('ID')?>"/>
<div class="x-form-container">
	<div class="form-message"></div>
	<table width="100%" cellpadding="4" class="x-form">
		<tr>
			<td class="x-form-label" style="width:133px">Mã: </td>
			<td class="x-form-input">
				<input valid="[{type: 'ajax', url: '<?php _e(baseUrl().'/Crm/Helper/Customercode') ?>', name: 'code' }]" class="x-text" type="text" name="code" value="<?php _e($post['code'])?>" style="width:150px;"/>
			</td>
		</tr>
		
			<tr>
				<td class="x-form-label">Tên công ty: </td>
				<td class="x-form-input">
					<input class="x-text" type="text" name="name" value="<?php _e($post['name'])?>" style="width:400px"/>
				</td>
			</tr>
			
			<tr>
				<td class="x-form-label">Ngành nghề: </td>
				<td class="x-form-input">
					<select name="trade_id" class="x-select">
					<?php foreach( $this->get('trades') as $a ):?>
					<option value="<?php _e($a['ID']);?>"<?php if($post['trade_id']==$a['ID']) _e(' selected')?>><?php _e($a['title']);?></option>
					<?php endforeach;?>
					</select>
				</td>
			</tr>

			<tr>
				<td class="x-form-label">Nhóm công ty: </td>
				<td class="x-form-input">
					<select name="parent_id" class="x-select">
					<?php foreach( $this->get('cats') as $a ):?>
					<option value="<?php _e($a['ID']);?>"<?php if($post['parent_id']==$a['ID']) _e(' selected')?>><?php _e($a['title']);?></option>
					<?php endforeach;?>
					</select>
				</td>
			</tr>
			
			<tr>
				<td class="x-form-label" valign="top"> Khu vực : </td>
				<td class="x-form-input">
					<div>
					<select name="country_id" style="min-width:280px" class="x-select" onchange="load_state(this)">
						<option style="color:#ccc">Quốc gia</option>
						<?php foreach( $this->get('countries') as $a ):?>
						<option value="<?php _e($a['ID']);?>"<?php if($post['country_id']==$a['ID']) _e(' selected')?>><?php _e($a['title']);?></option>
						<?php endforeach;?>
					</select><br/>				
				
					<select dt="state"  onchange="load_district(this)" style="min-width:280px" name="state_id" class="x-select">
						<option>Tỉnh thành</option>
						<?php foreach( (array)$this->get('states') as $a ):?>
						<option value="<?php _e($a['ID']);?>"<?php if($post['state_id']==$a['ID']) _e(' selected')?>><?php _e($a['title']);?></option>
						<?php endforeach;?>						
					</select><br/>
					<select dt="district" style="min-width:280px" name="district_id" class="x-select">
						<option>Quận huyện</option>
						<?php foreach( (array)$this->get('districts') as $a ):?>
						<option value="<?php _e($a['ID']);?>"<?php if($post['district_id']==$a['ID']) _e(' selected')?>><?php _e($a['title']);?></option>
						<?php endforeach;?>						
					</select>
					<br/>
					</div>
				</td>
			</tr>
			<tr>
				<td class="x-form-label">Trụ sở: </td>
				<td class="x-form-input">
					<input class="x-text" type="text" name="address" style="width:400px;"  value="<?php _e($post['address']);?>"/>
				</td>
			</tr>
			
			<tr>
				<td class="x-form-label">Điện thoại: </td>
				<td class="x-form-input">
					<input class="x-text" type="text" name="phone" style="width:150px;" value="<?php _e($post['phone']);?>"/>
				</td>
			</tr>

			<tr>
				<td class="x-form-label">Fax: </td>
				<td class="x-form-input">
					<input class="x-text" type="text" name="fax" style="width:150px;" value="<?php _e($post['fax']);?>"/>
				</td>
			</tr>
			
			<tr>
				<td class="x-form-label">Email: </td>
				<td class="x-form-input">
					<input class="x-text" type="text" name="email" style="width:400px;" value="<?php _e($post['email']);?>"/>
				</td>
			</tr>			
			
			<tr>
				<td class="x-form-label">Website: </td>
				<td class="x-form-input">
					<input class="x-text" type="text" name="website" value="<?php _e($post['website']);?>" style="width:400px;"/>
				</td>
			</tr>			
			
			<tr>
				<td class="x-form-label">Sinh nhật công ty: </td>
				<td class="x-form-input">
					<input type="text" name="birthday" value="<?php _e(show_date('d/m/Y',$post['birthday']));?>" onclick="date_picker(this,{format: 'd/m/Y' })" class="x-text x-date"/>
				</td>
			</tr>			
			
			<tr>
				<td class="x-form-label">Chăm sóc: </td>
				<td class="x-form-input">				
					<?php _e(tpl_select_user('care_by_id','',$this->get('care')));?>
				</td>
			</tr>

			<tr>
				<td class="x-form-label">Mô tả: </td>
				<td class="x-form-input">
					<textarea class="x-text" name="desc" style="width:500px;height:100px"><?php _e($post['desc']);?></textarea>
				</td>
			</tr>

			<tr>
				<td class="x-form-label" align="center" valign="top">
					<span class="x-attachment"></span>
				</td><!--FILES-->
				<td class="x-form-input" valign="top">
					<?php foreach( $this->get('files') as $file ):?>
					<div class='x-file-info'>
						<input checked type='checkbox' name='files[]' value='<?php _e($file['ID']);?>'/>
						<a href="<?php _ctrUrl($this);?>/File?ID=<?php _e($file['ID']);?>" target="_blank"><?php _e($file['filename']);?> <?php _e($file['size']);?> KB	</a>
					</div>
					<?php endforeach;?>				
					<div class="x-files" url="<?php _baseUrl();?>/Crm/Customer/Upload?post_id=<?php $this->e('ID')?>"></div>
				</td>
			</tr>			
			
			<tr>
				<td></td>
				<td class="x-form-input">
					<input type="submit" value="Cập nhật" class="x-button x-save"/>
					<a href="#Crm/Customer" class="x-button x-fresh">Hủy bỏ</a>
				</td>
			</tr>
	</table>
</div>
</form>
